/**
 * dinosnes.c
 *
 * Main driver program for DinoSNES
 *
 * @author  Philippe Johnson
 */

#include "common.h"
#include "rommanager.h"
#include "snes.h"

#include <string.h>

int main( int argc, char* argv[] ) {
    char*         cmd;
    int           i = 1;
    CartridgeInfo ci;

    if( argc == 0 ) {
	DEBUGMSG( "Usage: dinosnes -f romname.smc" );
        goto Exit;
    }

    /* Iterate through arguments & parse accordingly */
    while( i < argc ) {
        if(!strncmp(argv[i], "-f", 2)) {
            /* Load the file */
            if( !loadCartridge( argv[i + 1], &ci ) ) {
                DEBUGMSG( "main: could not load rom %s\n", argv[i + 1] );
            } else {
                DEBUGMSG( "Rom loaded!\n" );
            }

	    i += 2;/* One for -f token, another for filename */
        }
    }

    /* TODO: Begin execution! */
    initializeSNES( &ci );

    runSNES();

    unloadRom();

Exit:
    return 0;
}
